from turtle import *

def get_info():
    try:
        global num_site
        num_site = int(input("需要画出几个点？"))
    except ValueError:
        print("请输入一个正整数")
    except:
        print("未知错误")
    if num_site < 6:
        site_ls = []
        for i in range(num_site):
            site_ls.append("(x{0},y{0})".format(i+1))
        print("假设各点的坐标分别为{}，请依次输入各个点的横、纵坐标：".format(", ".join(site_ls)),end="\n")
    else:
        print("假设各点的坐标分别为(x1,y1), (x2,y2), (x3,y3)......(x{0},y{0}，请依次输入各个点的横、纵坐标：)".format(num_site),end="\n")
    for i in range(num_site):
        exec("global x{}".format(i+1))
        exec("x{0} = eval(input('x{0}='))".format(i+1))
        exec("global y{}".format(y+1))
        exec("y{0} = eval(input('y{0}='))".format(i+1))
        print("\n")



def turtle_set():
    pensize(3)
    speed(10)
    penup()
    goto(-200,-200)
    pendown()

def line(mark_angle):
    for i in range(num_site):
        fd(100)
        left(mark_angle)
        fd(5)
        bk(5)
        right(mark_angle)
    fd(105)
    begin_fill()
    tri_angle = [150,120,120]
    for i in range(3):
        left(tri_angle)
        fd(10)
    end_fill()

def dot():
    penup()
    goto(x1 - 200,y1 - 200)
    pendown()
    for i in range(num_site - 1):
        goto(eval("x{0} - 200,y{0} - 200".format(i+2)))
        dot(8)

def main():
    get_info()
    turtle_set()
    line(90)
    goto(-200,-200)
    seth(90)
    line(270)
    dot()
    hideturtle()
    done()

main()
